<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>添加操作学生</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }

        .flex_center_row {
            display: flex;
            flex-direction: row;
            justify-content: center;
        }
    </style>
</head>

<body>
    <div class="layui-row layui-col-space15 flex_center_row">
        <div class="layui-col-md6">
            <div class="layui-panel">
                <div style="padding: 30px;">
                    <!-- 内容 -->
                    <div class="layui-form layuimini-form" lay-filter="super">
                        <div class="layui-form-item">
                            <label class="layui-form-label required">学生姓名</label>
                            <div class="layui-input-block">
                                <input type="text" name="student_name" lay-verify="required" lay-reqtext="学生姓名不能为空"
                                    placeholder="请输入学生姓名" value="" class="layui-input">
                                <tip>小程序端登录的学生姓名--例 xxx</tip>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label required">用户名</label>
                            <div class="layui-input-block">
                                <input type="text" name="username" lay-verify="required" lay-reqtext="用户名不能为空"
                                    placeholder="请输入用户名" value="" class="layui-input">
                                <tip>小程序端登录的用户名--例 admin</tip>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label required">密码</label>
                            <div class="layui-input-block">
                                <input type="text" name="password" lay-verify="required" lay-reqtext="密码不能为空"
                                    placeholder="请输入密码" value="" class="layui-input">
                                <tip>小程序端登录的密码--例 123456</tip>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
    <script src="../../var/var.js"></script>
    <script>
        layui.use(['form'], function () {
            var form = layui.form,
                layer = layui.layer,
                $ = layui.$;
            //监听提交
            form.on('submit(saveBtn)', function (data) {
                var index = JSON.stringify(data.field)
                $.ajax({
                    url: UrlStr + '/op/create',
                    data: index,
                    headers: { Authorization: layui.data("token")["token"] },
                    type: "post",
                    dataType: "json",
                    success: function (data) {
                        if(data.code!=1000){
                            layer.msg(data.msg);
                        }
                        if (data.code == 1000) {
                            layer.msg('修改成功');
                        }
                    }
                })
            });

        });
    </script>
</body>

</html>